var ec_right2 = echarts.init(document.getElementById("r2"),'my');

// 从后端获取数据
$.get("/r2", function(resp) {
    var industry = resp.industry;
    var increase_ratio = resp.increase_ratio;

    // 使用获取到的数据渲染图表
    option_right2 = {
        title: {
            text: '行业涨幅占比',
            left: 'center',
            textStyle: {
                color: '#fff'
            }
        },
        backgroundColor: 'transparent',
        tooltip: {
            trigger: 'item',
            formatter: '{b}: {d}%'
        },
        series: [{
            name: '涨幅占比',
            data: increase_ratio.map(function(item, index) {
                return {
                    name: industry[index],
                    value: item
                };
            }),
            type: 'pie',
            radius: '55%',
            center: ['50%', '60%'],
            color: ['#FFD700', '#BFEFFF', '#FFC0CB', '#7B68EE', '#00FA9A'],
            label: {
                show: true,
                formatter: '{b}: {d}%',
                textStyle: {
                    color: '#fff'
                },
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowOffsetY: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
            },
            emphasis: {
                label: {
                    show: true,
                    fontSize: '14',
                    fontWeight: 'bold'
                }
            },
            itemStyle: {
                borderWidth: 1,
                borderColor: '#fff',
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }]
    };

    // 使用 option_right2 配置项初始化图表
    ec_right2.setOption(option_right2);
    
});
